package com.xjm.ips.controller.personnel;

import com.xjm.ips.entity.AjaxJson;
import com.xjm.ips.entity.Employee;
import com.xjm.ips.entity.Employeeremove;
import com.xjm.ips.entity.MyPage;
import com.xjm.ips.service.EmployeeBasiService;
import com.xjm.ips.service.PersonnelRemoveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/personnel/remove")
public class PersonnelRemoveController {
    @Autowired
    PersonnelRemoveService personnelRemoveService;
    @Autowired
    EmployeeBasiService employeeBasiService;

    @GetMapping("/")
    public MyPage getAllEmployeeRemoves(@RequestParam(defaultValue = "1") Integer pageNo,
                                        @RequestParam(defaultValue = "10") Integer pageSize){
        return personnelRemoveService.getAllEmployeeRemoves(pageNo,pageSize);
    }

    @DeleteMapping("/{id}")
    public AjaxJson deleteEmployeeRemoves(@PathVariable Integer id){
        if(personnelRemoveService.deleteEmployeeRemoves(id)==1){
            return AjaxJson.ok("删除部门调整信息成功!");
        }
        return AjaxJson.error("删除部门调整信息失败!");
    }


    /**
     * 分页查询员工资料，传页数和条数，不传则默认第一页10条
     */
    @GetMapping("/getEmpOfNotWork")
    public MyPage getEmpOfNotWork(@RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "10") Integer pageSize, Employee employee){
        return employeeBasiService.getEmpOfNotWork(pageNo,pageSize,employee);
    }

    @DeleteMapping("/deleteEmpRemove/{id}")
    public AjaxJson deleteEmpRemove(@PathVariable Integer id){
        if(employeeBasiService.deleteEmpRemove(id)==1){
            return AjaxJson.ok("删除员工离职记录成功!");
        }
        return AjaxJson.error("删除员工离职记录失败!");
    }
}
